﻿<!doctype html>
<html lang="en">
<head>
    <script type="text/javascript" src="js/jquery-2.1.3.js"></script>
    <script type="text/javascript" src="js/highstock.js"></script>
    <script type="text/javascript" src="js/modules/exporting.js"></script>
    <script type="text/javascript" src="js/chu/chu_common.js"></script>
    <script>
        $(function () {

            // http://localhost/rest/rest/analyze?end=20150304&level=1&start=20140901

            var end_date = "end", level = "level", start_date = "start", tag = "tag", old = "old",daybefore="daybefore",industry="industry",location="location",type="type";
            tag = chu_common.parsepara(tag);
            end_date = chu_common.parsepara(end_date);
            level = chu_common.parsepara(level);
            start_date = chu_common.parsepara(start_date);
            old = chu_common.parsepara(old);
            daybefore = chu_common.parsepara(daybefore);
            industry = chu_common.parsepara(industry);
            location = chu_common.parsepara(location);
            type = chu_common.parsepara(type);



            var url = "/rest/rest/analyze?old=" + old + "&level=" + level + "&tag=" + tag + "&daybefore=" + daybefore+"&industry=" + industry+"&location="+location+"&type="+type;
            $.ajaxSetup({ async: false });
            var t = $.getJSON(url, function (data) {
                for (var i in data) {
                    var newRow = "<tr>";
                    var big = data[i]["big"];
                    var sid = data[i]["sid"];


                    var link = "<a target='_parent' href='/web/single_dynamic.html?sid=" + sid + "&big=" + big + "'>" + sid + "</a>";
                    newRow += "<td>" + link + "</td>";
                    newRow += "<td>" + data[i]["name"] + "</td>";

                    var ind1 = data[i]["firstlevel"];
                    var ind2 = data[i]["secondlevel"];

                    var ind_link1 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "'>" + ind1 + "</a>";
                    newRow += "<td>" + ind_link1 + "</td>";
                    var ind_link2 = "<a target='_parent' href='/web/company.html?industry1=" + ind1 + "&industry2=" + ind2 + "'>" + ind2 + "</a>";
                    newRow += "<td>" + ind_link2 + "</td>";

                    var enddate = data[i]["enddate"];
                    var startdate = data[i]["startdate"];

                    $("#time").text("Start:" + startdate + "  End:" + enddate);

                    //newRow += "<td>" + start_date + "</td>";
                    //newRow += "<td>" + end_date + "</td>";
                    

                    var y = "/rest/rest/analyzevalue?level=" + level + "&tag=" + tag + "&sid=" + sid + "&daybefore=" + daybefore;
                    var rankk = "";
                    $.ajaxSetup({ async: false });
                            $.getJSON(y, function (data2) {
                                rankk = data2;
                            });
                            newRow += "<td>" + rankk + "</td>";
                    //newRow += "<td>" + data[i]["rank"] + "</td>";
                    newRow += "<td>" + data[i]["value"] + "</td>";
                    
                    var url_1 = "/rest/rest/infoext/id/" + sid;
                    $.ajaxSetup({ async: false });
                    $.getJSON(url_1, function (data1) {
                        newRow += "<td>" + data1["shiyinglv"] + "</td>";
                        newRow += "<td>" + data1["shijinglv"] + "</td>";
                        newRow += "<td>" + data1["jingzichan"] + "</td>";
                        newRow += "<td>" + data1["shourutongbi"] + "</td>";
                        newRow += "<td>" + data1["jingliruntongbi"] + "</td>";
                        newRow += "<td>" + data1["meiguweifenpeilirun"] + "</td>";
                        newRow += "<td>" + data1["zongguben"] + "</td>";
                        newRow += "<td>" + data1["liutonggu"] + "</td>";
                    });

                    var url_2 = "/rest/rest/latestprice/id/" + sid+"?tag="+tag;
                    $.ajaxSetup({ async: false });
                    $.getJSON(url_2, function (data) {
                        newRow += "<td>" + data + "</td>";
                    });
                    var url_3 = "/rest/rest/maxmin/id/" + sid + "?range=12";
                    $.ajaxSetup({ async: false });
                    $.getJSON(url_3, function (data) {
                        newRow += "<td>" + data + "</td>";

                    });
                    //var url_4 = "/rest/rest/maxmin/id/" + sid + "?range=24";
                    //$.ajaxSetup({ async: false });
                    //$.getJSON(url_4, function (data) {
                    //    newRow += "<td>" + data + "</td>";

                    //});

                    $("#table1 tr:last").after(newRow);
                }
                var hh = "<tr><th>id</th><th>名字</th><th>行业1</th><th>行业2</th><th>24,12,6,3</th><th>得分</th><th>市盈率</th><th>市净率</th><th>净资产</th><th>收入<br>同比(%)</th><th>净资产<br>同比(%)</th><th>每股未<br>分配利润</th><th>总股本</th><th>流通股</th><th>当前<br>股价</th><th>12月<br>最值</th></tr>";
                $("#table1 tr:last").after(hh);
            });
        });

    </script>
</head>
<body>
    <div id="time"></div>
    <div id="input">
        <table id="table1" border="1"><tr><th>id</th><th>名字</th><th>行业1</th><th>行业2</th><th>24,12,6,3</th><th>得分</th><th>市盈率</th><th>市净率</th><th>净资产</th><th>收入<br>同比(%)</th><th>净资产<br>同比(%)</th><th>每股未<br>分配利润</th><th>总股本</th><th>流通股</th><th>当前<br>股价</th><th>12月<br>最值</th></tr></table>
    </div>

    <a id="industry1" href=""></a>
    
</body>
</html>